require File.expand_path(File.dirname(__FILE__) + "/../config/environment")

class BatchLoadGuestData < BatchBase
  Account.transaction do
    created_time = Time.now - 14.day
    p "_____insert accounts"
    accounts = Account.new( :code => '000000', :name => 'ゲスト',
                            :section => 'guest', :email => 'info@openskip.org',
                            :password => 'guest',
                            :password_confirmation => 'guest',
                            :created_at => created_time,
                            :updated_at => created_time )
    accounts.save!

    p "_____insert user"
    user = User.new(:updated_on => created_time,
                    :name => 'ゲスト',
                    :extension => 000000,
                    :created_on => created_time,
                    :introduction => 'よろしくお願いします。',
                    :retired => 0,
                    :section => 'guest',
                    :email => 'info@openskip.org')
    user.save!

    p "_____insert user_uid"
    user_uid = UserUid.new(:uid => '000000',
                           :uid_type => UserUid::UID_TYPE[:master],
                           :user_id => user.id)
    user_uid.save!


    p "_____insert profile"
    user_profile = UserProfile.new(:birth_month => 1,
                                   :hobby => '',
                                   :join_year => 2008,
                                   :blood_type => 1,
                                   :address_1 => 1,
                                   :alma_mater => '非公開',
                                   :birth_day => 1,
                                   :disclosure => 0,
                                   :gender_type => 1,
                                   :address_2 => '非公開',
                                   :introduction => '',
                                   :user_id => user.id,
                                   :hometown => 1)
    user_profile.save!

    p "_____insert user_access"
    user_access = UserAccess.new(:user_id => user.id, :last_access => Time.now, :access_count => 0)
    user_access.save!
  end
end
